package com.alks.function.controller.produce;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.produce.LabelQueryRequest;
import com.alks.function.data.request.produce.LabelRequest;
import com.alks.function.data.request.produce.PartNameQtyRequest;
import com.alks.function.mapper.produce.ComponentLabelMapper;
import com.alks.function.service.produce.ComponentLabelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@ApiRestController("/label/plan")
@Api(tags ={ "生产部-生产作业-生产标签-部件标签"})
@Slf4j
public class ComponentLabelsController {

    @Autowired
    private ComponentLabelService componentLabelService;

    @Autowired
    private ComponentLabelMapper componentLabelMapper;

    @WebLogger
    @PostMapping("/ComponentLabelQuery")
    @ApiOperation(value = "查询",tags = "生产部-生产作业-生产标签-部件标签")
    public ResponseInfo ComponentLabelQuery(@RequestBody LabelQueryRequest request){
        return componentLabelService.ComponentLabelQuery(request);
    }

    @WebLogger
    @GetMapping("/getCustomList")
    @ApiOperation(value = "客户",tags = "生产部-生产作业-生产标签-部件标签")
    public ResponseInfo getCustomList(){
        return ResponseInfo.ok(componentLabelMapper.getCustomList());
    }

    @WebLogger
    @GetMapping("/getStyleList")
    @ApiOperation(value = "型体",tags = "生产部-生产作业-生产标签-部件标签")
    public ResponseInfo getStyleList(){
        return ResponseInfo.ok(componentLabelMapper.getStyleList());
    }

    @WebLogger
    @PostMapping("/LabelDetails")
    @ApiOperation(value = "标签明细",tags = "生产部-生产作业-生产标签-部件标签")
    public ResponseInfo LabelDetails(@RequestBody LabelRequest request){
        return componentLabelService.LabelDetails(request);
    }

    @WebLogger
    @PostMapping("/generate/{lotNo}")
    @ApiOperation(value = "确定",tags = "生产部-生产作业-生产标签-部件标签")
    public ResponseInfo generate(@RequestBody List<PartNameQtyRequest> list,@PathVariable String lotNo){
        return componentLabelService.generate(lotNo,list);
    }

    @WebLogger
    @PostMapping("/generate/check")
    @ApiOperation(value = "生成轮次标签",tags = "生产部-生产作业-生产标签-部件标签")
    public ResponseInfo checkLsInfo(@RequestParam String lotNo, @RequestParam boolean override){
        return componentLabelService.checkLsInfo(lotNo,override);
    }

    @WebLogger
    @PostMapping({"/set/list"})
    @ApiOperation(value = "冲裁部位袋装规格定义查询",tags = "生产部-生产作业-生产标签-部件标签")
    public ResponseInfo partList(@RequestParam String lotNo) {
        return componentLabelService.partList(lotNo);
    }

    @WebLogger
    @PostMapping("/generate/delete")
    @ApiOperation(value = "删除轮次标签",tags = "生产部-生产作业-生产标签-部件标签")
    public ResponseInfo deleteLabel(@RequestParam String lotNo) {
        return componentLabelService.deleteLabel(lotNo);
    }

    @WebLogger
    @GetMapping("/loadMaxlsNo")
    @ApiOperation(value = "打印标签-轮次",tags = "生产部-生产作业-生产标签-部件标签")
    public ResponseInfo loadMaxlsNo(@RequestParam String lotNo) {
        return componentLabelService.loadMaxlsNo(lotNo);
    }

    @WebLogger
    @PostMapping("/printLabel")
    @ApiOperation(value = "打印标签-打印", tags = "生产部-生产作业-生产标签-部件标签")
    public ResponseInfo printLabel(@RequestParam List<String> partNames, @RequestParam String lotNo, @RequestParam Integer lsFrom, @RequestParam(required = false) Integer lsEnd, @RequestParam(required = false) List<String> sizeNos) {
        return componentLabelService.getPrintLabelList(partNames, lotNo, lsFrom, lsEnd, sizeNos);
    }
}
